﻿//===============================================================================
// La Pomme d'Or Krystal Application
// Windows Presentation Foundation Composite Application 
//===============================================================================
// Copyright (c) Jérôme Piquot.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;

namespace PJ.Data
{
    /// <summary>
    /// <see cref="IOrderedFragmentData">Ordered Fragment data</see> provider interface
    /// </summary>
    public interface IOrderedFragmentProvider : IEntityFragmentProvider
    {
        /// <summary>
        /// Moves up the fragment in the ordered collection
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to move</param>
        /// <returns>new fragment order</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        /// <exception cref="ArgumentException">If the passed <paramref name="order"/> does not exist</exception>
        /// <exception cref="ArgumentOutOfRangeException">If the passed <paramref name="order"/> is the first fragment</exception>
        double Up(string parentId, double order);

        /// <summary>
        /// Moves down the fragment in the ordered collection
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to move</param>
        /// <returns>new fragment order</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        /// <exception cref="ArgumentException">If the passed <paramref name="order"/> does not exist</exception>
        /// <exception cref="ArgumentOutOfRangeException">If the passed <paramref name="order"/> is the last fragment</exception>
        double Down(string parentId, double order);

        /// <summary>
        /// Checks if the fragment is the first in the list
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to check</param>
        /// <returns>true if the fragment is the first in the list, else false</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        /// <exception cref="ArgumentException">If the passed <paramref name="order"/> does not exist</exception>
        bool IsFirst(string parentId, double order);

        /// <summary>
        /// Checks if the fragment is the last in the list
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to check</param>
        /// <returns>true if the fragment is the last in the list, else false</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        /// <exception cref="ArgumentException">If the passed <paramref name="order"/> does not exist</exception>
        bool IsLast(string parentId, double order);

        /// <summary>
        /// Checks if a fragment exists in the list
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to find</param>
        /// <returns>true if the fragment is found, else false</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        bool OrderExists(string parentId, double order);

        /// <summary>
        /// Finds a fragment in the list by it's order.
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to find</param>
        /// <param name="mode">Fetch mode</param>
        /// <returns>The fragment object if found else throws an exception.</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        IOrderedFragmentData GetByOrder(string parentId, double order, GetDataMode mode);
    }
    /// <summary>
    /// <see cref="IOrderedFragmentData">Ordered Fragment data</see> provider interface
    /// </summary>
    /// <typeparam name="TIOrderedFragmentProvider"><see cref="IOrderedFragmentData">Ordered Fragment data</see> type</typeparam>
    public interface IOrderedFragmentProvider<TIOrderedFragmentProvider> : IEntityFragmentProvider<TIOrderedFragmentProvider>, IOrderedFragmentProvider
        where TIOrderedFragmentProvider : class, IOrderedFragmentData
    {
        /// <summary>
        /// Finds a fragment in the list by it's order.
        /// </summary>
        /// <param name="parentId">The fragment list id</param>
        /// <param name="order">The actual order of the fragment to find</param>
        /// <param name="mode">Fetch mode</param>
        /// <returns>The fragment object if found else throws an exception.</returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="parentId"/> is <see langword="null" /> or empty.</exception>
        new TIOrderedFragmentProvider GetByOrder(string parentId, double order, GetDataMode mode);
    }
}
